#ifndef GRAPHIC_ENGINE_HH_
#	define GRAPHIC_ENGINE_HH_

# 	include "tools/Matrix.hh"

class GraphicEngine
{
    public:
        /// default Ctor
        GraphicEngine();

        /// Ctor
        GraphicEngine(float fov, float ratio, float near, float far);

        /// Dtor
        ~GraphicEngine();

        /** returns matrix product: Projection * View * Model
         ** where Projection is _perspective,
         ** View is _camera
         */
        Matrix getMVP();

        /** _camera getter
         */
        Matrix getCamera();

        /** _camera position setter */
        void setCameraPosition(float x, float y, float z);

        /// camera motion
        void moveCamera(float x, float y, float z);

        /// camera rotation
        void turnCamera(float x, float y, float z);

        /// side tilting camera
        void tiltCamera(float x, float y, float z);

        /** Sets the Matrix \param model as _model */
        void setModel(Matrix model);

        /** Sets the perspective (Projection) Matrix */
        void updatePerspective();

        /** Calculate all perspective needs, filling attributes
         ** \param fov: field of view, camera angle
         ** \param ratio: aspect ratio, horizontal ratio
         ** \param zNear: from which distance we'll start to draw
         ** \param zFar: till where we'll draw
         */
        void calcPerspective(float fov, float ratio, float zNear, float zFar);

        /** Applies perspective on the \param model Matrix
         ** using previously calculated attributes
         */
        //void applyPerspective(Matrix &model);

        /** Sets the camera Matrix */
        void setCamera(Matrix c);

        /** \return projection Matrix
         */
        Matrix perspective(float fov, float ratio, float near, float far);

    private:
        float _fov; 	    	/// field of view
        float _aspectRatio;     /// screen ratio

        float _zNear; 	    	/// from which distance we'll start drawing
        float _zFar;  		    /// from where we'll stop drawing

        // these ones are here to avoid recalculating their values for each draw
        float _zRange;   		/// drawing range (== _zFar - _zNear)
        float _distance;    	/// distance camera <-> projection window

        Matrix _model;			/// Model
        Matrix _camera;			/// View
        Matrix _perspective;	/// Projection
};

#endif /* !ENGINEGRAPHIC_HH_ */
